let fs = require("fs"); //fileSystem 文件系统
fs.readFile("./src/main.js", { encoding: "utf-8" }, (err, data) => {
  // console.log(data);
  fs.writeFile("./dist/main.js", data, () => {
    //js已经生成了

    fs.readFile("./public/index.html", { encoding: "utf8" }, (err, html) => {
      // fs.writeFile("./dist/index.html",data,()=>{
      //     console.log("写入完成");
      // })
      let newHtml = html.replace(
        "</body>",
        "</body><script src='./main.js'></script>"
      );

      fs.writeFile("./dist/index.html", newHtml, () => {
        console.log("写入成功");
      });
    });
  });
});
